package com.x.mvp.utils;

/**
 * Created by Hwang on 2016/5/26.
 */
public class AlipayResultUtil {

    public static String getResultStatus(String rawResult) {
        String resultStatus = "";
        String[] resultParams = rawResult.split(";");
        for (String resultParam : resultParams) {
            if (resultParam.startsWith("resultStatus")) {
                resultStatus = gatValue(resultParam, "resultStatus");
            }
        }
        return resultStatus;
    }

    private static String gatValue(String content, String key) {
        String prefix = key + "={";
        return content.substring(content.indexOf(prefix) + prefix.length(),
                content.lastIndexOf("}"));
    }
}
